#include <iostream>
using namespace std;

class A
{
public:
    A(int a, int b)
    {
        this->a = a;
        this->b = b;
    }

    virtual void print()
    {
        printf("a = %d, b = %d\n", this->a, this->b);
    }

protected:
    int a;
    int b;
};

class B:public A
{
public:
    B(int a, int b, int c):A(a,b)
    {
        this->c = c;
    }
    void print()
    {
        printf("a = %d, b = %d, c = %d\n", this->a, this->b, this->c);
    }
private:
    int c;
};

void print(A * p)
{
    p->print();
}
int main()
{
    A a(1,2);
    B b(4,5,6);
    print(&a);
    print(&b);


    return 0;
}